package com.any.hook.common.element;

import com.alibaba.fastjson.JSON;

import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Date;

public abstract class Column {
    private Object rawData;
    private int byteSize;
    private Type type;

    public Column(Object rawData, int byteSize, Type type) {
        this.rawData = rawData;
        this.byteSize = byteSize;
        this.type = type;
    }

    public Object getRawData() {
        return rawData;
    }

    protected void setRawData(Object rawData) {
        this.rawData = rawData;
    }

    public int getByteSize() {
        return byteSize;
    }

    protected void setByteSize(int byteSize) {
        this.byteSize = byteSize;
    }

    public Type getType() {
        return type;
    }

    protected void setType(Type type) {
        this.type = type;
    }

    public abstract Long asLong();
    public abstract Double asDouble();
    public abstract String asString();
    public abstract Date asDate();
    public abstract byte[] asBytes();
    public abstract Boolean asBoolean();
    public abstract BigDecimal asBigDecimal();
    public abstract BigInteger asBigInteger();

    @Override
    public String toString() {
        return JSON.toJSONString(this);
    }

    public enum Type{
        BAD,NULL,INT,LONG,DOUBLE,STRING,BOOL,DATE,BYTES
    }
}
